package net.zjitc.servlet;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by Administrator on 2017/9/25.
 */
public class GServlet extends GenericServlet{
    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

        //如何获得servletConfig,已经有方法了，可以直接用
        ServletConfig config=this.getServletConfig();
        String value=config.getInitParameter("gKey");
        PrintWriter out=servletResponse.getWriter();
        out.write("gServlet value=");
        out.write(value +"<br/>");

        ServletContext context=this.getServletContext();
        String path=context.getRealPath("/");
        out.write(path);
        out.write("我的页面");
    }
}
